const path = require("path");

exports.nunjucks = {
  enable: true,
  package: "egg-view-nunjucks",
};
exports.handlebars = {
  enable: true,
  package: "egg-view-handlebars",
};
exports.ejs = {
  enable: true,
  package: "egg-view-ejs",
};

exports.mysql = {
  enable: true,
  package: "egg-mysql",
};

exports.sequelize = {
  enable: true,
  package: "egg-sequelize",
};

exports.onerror = {
  accepts: (ctx) => {
    if (ctx.get("content-type") === "application/json") return "json";
    return "html";
  },
  all(err, ctx) {
    console.log("-----sssss");
    // 在此处定义针对所有响应类型的错误处理方法
    // 注意，定义了 config.all 之后，其他错误处理方法不会再生效
    ctx.body = "error";
    ctx.status = 500;
  },
  html(err, ctx) {
    // 处理 html hander
    ctx.body = "<h3>error</h3>";
    ctx.status = 500;
  },
  json(err, ctx) {
    // json hander
    ctx.body = { message: "error" };
    ctx.status = 500;
  },
};
